package com.atguigu.gmall.product.rpc.controller;


import com.atguigu.gmall.model.product.BaseCategoryView;
import com.atguigu.gmall.model.rpc.product.BaseCategory;
import com.atguigu.gmall.product.service.BaseCategory1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 1、只要是远程调用服务  都已 "/api/inner/**"，代表提供给内部微服务之间调用的
 */
@RequestMapping("/api/inner")
@RestController
public class CategoryController {

    @Autowired
    BaseCategory1Service baseCategory1Service;

    @GetMapping("/category/all")
    public List<BaseCategory> getAllCategory() {

        List<BaseCategory> categories = baseCategory1Service.getAllCategoryForIndexPage();
        return categories;
    }

    @GetMapping("/category/sku/{skuId}")
    public BaseCategoryView getCategoryPathBySkuId(@PathVariable("skuId") Long skuId) {

        BaseCategoryView view = baseCategory1Service.getCategoryPathBySkuId(skuId);
        return view;
    }


}
